package com.dataart.productshop.dao.impl;

import com.dataart.productshop.dao.PictureDao;
import com.dataart.productshop.model.FileInfo;
import com.dataart.productshop.model.Picture;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class PictureDaoImpl extends BaseDaoImpl<Picture> implements PictureDao {

	public PictureDaoImpl() {
		super(Picture.class);
	}

	@Override
	public void savePicture(Picture picture) {
		getHibernateTemplate().save(picture);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Picture> getPictureByFileInfo(FileInfo fileInfo) {
		return createCriteria(Picture.class).add(Restrictions.eq("fileInfo", fileInfo)).list();
	}

	@Override
	public Picture getPictureById(Long id) {
		return getById(id);
	}
	
}
